package kr.hkit.powerjava.chapter24;

import java.io.*;

public class CopyFileReader {
	public static void main(String[] args) {
		FileReader fr = null;
		FileWriter fw = null;
		try {
			fr = new FileReader("input.txt");
			fw = new FileWriter("output2.txt");
			int c;
			while((c = fr.read()) != -1){
				System.out.printf("%s",(char)c);
				fw.write(c);
				
			}
		} catch (FileNotFoundException e) {
			System.err.format("%s%n", "파일이 존재 하지 않음");
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		} finally{
			if(fr != null){
				try {fr.close();} catch (IOException e) {e.printStackTrace();}
			}
			if(fw != null){
				try {fw.close();} catch (IOException e) {e.printStackTrace();}
			}
		}
	}
}
